Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#348193 - 20/10/2011 13:05 htaccess - remove "index.html" and "index.php" from urls
hybrid8
carpal tunnel

Registered: 12/11/2001
Posts: 7738
Loc: Toronto, CANADA
Ok, this is driving me batty. I'm trying to remove any instance of index.html or index.php on any URL, preserving the entire path before the matched string and also preserving any arguments that may be passed after.

The goal here is that whatever index file may be passed on the URL, the default/existing index file for that path will always be used, since the server already searches for various index file extensions automatically. This has the benefit of allowing me to change from html to php for any index file without affecting existing links elsewhere on the web and also cleans up the various base/sub-base URLs in browsers.

The other reason is to overcome a limitation with Google analytics where they only allow a single "default" page, such as "index.html" to be defined, even though my site uses both static and dynamic pages and therefor has both .html and .php scattered around.

Just testing with index.php for a moment, I tried this:

Code:
RewriteCond %{THE_REQUEST} /index.php HTTP
RewriteRule (.*)index.php$ /$1 [NC,L]


However it fails, causing nothing on the site to work at all.

Quote:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


Any ideas?


Edited by hybrid8 (20/10/2011 13:23)
_________________________
Bruno
Twisted Melon : Fine Mac OS Software

Top
#348195 - 20/10/2011 14:00 Re: htaccess - remove "index.html" and "index.php" from urls [Re: hybrid8]
tonyc
carpal tunnel

Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
What's in the Apache error log?

mod_rewrite isn't usually enabled by most default Apache configs -- are you sure it's loaded?
_________________________
- Tony C
my empeg stuff

Top
#348196 - 20/10/2011 14:09 Re: htaccess - remove "index.html" and "index.php" from urls [Re: tonyc]
hybrid8
carpal tunnel

Registered: 12/11/2001
Posts: 7738
Loc: Toronto, CANADA
Mod_rewrite is definitely loaded because I have another rewrite that works properly to rewrite the URL without www, among others.

As far as the apache log goes, I'm not certain where to find it on this shared host, nor if I can find it. Took a quick look through my logs folder already.
_________________________
Bruno
Twisted Melon : Fine Mac OS Software

Top
#348197 - 20/10/2011 14:42 Re: htaccess - remove "index.html" and "index.php" from urls [Re: hybrid8]
tonyc
carpal tunnel

Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
Try nuking the "HTTP" in the RewriteCond -- the "HTTP" predicate is used for rewriting header values (e.g. HTTTP:User-Agent) but I don't knwow if just plain putting "HTTP" in a rewrite condition makes sense.

But you should really try to find the error log to see what the error is -- grep for ErrorLog in your httpd.conf.


Edited by tonyc (20/10/2011 14:44)
_________________________
- Tony C
my empeg stuff

Top
#348198 - 20/10/2011 15:36 Re: htaccess - remove "index.html" and "index.php" from urls [Re: tonyc]
hybrid8
carpal tunnel

Registered: 12/11/2001
Posts: 7738
Loc: Toronto, CANADA
Thanks Tony.

I think I've got it now. The HTTP as you mentioned had to go - damn other people's examples.

I also wanted the rewrite to be reflected in the browser, so I had to force a redirect. This seems to work:

Code:
RewriteCond %{THE_REQUEST} /index\.php
RewriteRule (.*)index\.php$ /$1 [R]


I also escape the periods for good measure.
_________________________
Bruno
Twisted Melon : Fine Mac OS Software

Top